package Day5ExerciseAssignment;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;

import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MoreGuiThings extends javax.swing.JFrame {
	private JCheckBox chbAdvertising;
	private ButtonGroup bgTest;
	private JRadioButton rbtnAmex;
	private JRadioButton rbtnVisa;
	private JRadioButton rbtnMC;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MoreGuiThings inst = new MoreGuiThings();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public MoreGuiThings() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				chbAdvertising = new JCheckBox();
				getContentPane().add(chbAdvertising);
				chbAdvertising.setText("Send Me Advertising");
				chbAdvertising.setBounds(27, 19, 246, 19);
				chbAdvertising.addItemListener(new ItemListener() {
					public void itemStateChanged(ItemEvent evt) {
						
						//TODO add your code for chbAdvertising.itemStateChanged
						//JOptionPane.showMessageDialog(null, "New State: " + evt.getStateChange());
					}
				});
			}
			{
				rbtnMC = new JRadioButton();
				getContentPane().add(rbtnMC);
				rbtnMC.setText("MasterCard");
				rbtnMC.setSelected(true);
				rbtnMC.setBounds(27, 65, 187, 19);
				rbtnMC.addItemListener(new ItemListener() {
					public void itemStateChanged(ItemEvent evt) {
						//TODO add your code for rbtnMC.itemStateChanged
						if(evt.getStateChange() == ItemEvent.SELECTED)
						{
							System.out.println("you have selected MasterCard");
						}
					}
				});
				getBgTest().add(rbtnMC);
			}
			{
				rbtnVisa = new JRadioButton();
				getContentPane().add(rbtnVisa);
				rbtnVisa.setText("Visa");
				rbtnVisa.setBounds(27, 91, 187, 19);
				rbtnVisa.addItemListener(new ItemListener() {
					public void itemStateChanged(ItemEvent evt) {
						if(evt.getStateChange() == ItemEvent.SELECTED)
						{
							System.out.println("you have selected Visa");
						}
					}
				});
				getBgTest().add(rbtnVisa);
			}
			{
				rbtnAmex = new JRadioButton();
				getContentPane().add(rbtnAmex);
				rbtnAmex.setText("American Express");
				rbtnAmex.setBounds(27, 117, 187, 19);
				rbtnAmex.addItemListener(new ItemListener() {
					public void itemStateChanged(ItemEvent evt) {
						if(evt.getStateChange() == ItemEvent.SELECTED)
						{
							System.out.println("you have selected American Express");
						}
					}
				});
				getBgTest().add(rbtnAmex);
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private ButtonGroup getBgTest() {
		if(bgTest == null) {
			bgTest = new ButtonGroup();
		}
		return bgTest;
	}

}
